﻿using Prices;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace FileEncryptionTest
{
    
    
    /// <summary>
    ///This is a test class for ProductTest and is intended
    ///to contain all ProductTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ProductTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Product Constructor
        ///</summary>
        [TestMethod()]
        public void ProductConstructorTest()
        {
            string name = "pesho";
            int price = 1; 
            Product target = new Product(name, price);
            Assert.AreEqual(target.Name,name);
            Assert.AreEqual(target.Price, price);
        }

        /// <summary>
        ///A test for OnPriceIncrease
        ///</summary>
        [TestMethod()]
        public void OnPriceIncreaseTest()
        {
            string name = "pesho";
            int price = 1;
            Product target = new Product(name, price);
            bool executed = false;
            target.priceIncreased += delegate 
            {
                executed = true;
            };
            target.Price = 4;
            Assert.AreEqual(executed, true);
        }

        [TestMethod()]
        public void OnPriceNotIncreaseTest()
        {
            string name = "pesho";
            int price = 4;
            Product target = new Product(name, price);
            bool executed = false;
            target.priceIncreased += delegate
            {
                executed = true;
            };
            target.Price = 1;
            Assert.AreEqual(executed, false);
        }

        /// <summary>
        ///A test for Name
        ///</summary>
        [TestMethod()]
        public void NameTest()
        {
            string name = "pesho";
            int price = 5;
            Product target = new Product(name, price);
            string expected = "Gosho";
            string actual;
            target.Name = expected;
            actual = target.Name;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Price
        ///</summary>
        [TestMethod()]
        public void PriceTest()
        {
            string name = "pesho";
            int price = 5;
            Product target = new Product(name, price);
            int expected = 2;
            int actual;
            target.Price = expected;
            actual = target.Price;
            Assert.AreEqual(expected, actual);
        }
    }
}
